<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>创建对象的模式</title>
</head>
<body>
    
    <script>
    
        {
            // 工厂模式

            function createObj (name,age) {
                let obj = new Object();
                obj.name = name;
                obj.age = age;
                return obj;
            }

            console.log(createObj('ws',20));


        }

        {
            // 构造函数模式

            function Person (name,age) {
                this.name = name;
                this.age = age;
            }

            let person = new Person('ws',28);
            
            console.log(person);

        }

        

    </script>


</body>
</html>